#!/usr/bin/env python

import wx
import sys
import component

import resource as r

class Outbox(component.ListCtrl):
    '''Outbox class
    
    @author Julot <andy.julot@gmail.com>
    @since Thursday, March 01, 2012. 10:28 AM'''
    
    def __init__(self, parent):
        style = wx.LC_REPORT | wx.LC_SINGLE_SEL
        component.ListCtrl.__init__(self, parent, style=style)
        self.InsertColumn(1, r.string.view.progress.number)
        self.InsertColumn(2, r.string.view.progress.message)
        
        self.SetColumnWidth(1, wx.LIST_AUTOSIZE)
    
    @property
    def models(self):
        return None
    
    @models.setter
    def models(self, models):
        self.DeleteAllItems()
        for model in models:
            self.append(model)
    
    def append(self, model):
        index = self.InsertStringItem(sys.maxint, model.number)
        self.SetItemData(index, model.id)
        message = model.message.split('\n')[0]
        self.SetStringItem(index, 1, message)
